import java.util.Scanner;
public class Test {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        scanner.close();
        for(int i = 0;i <= x;i++){
            int is_num = 0;
            int z = (i / 100) % 10;
            int y = (i / 10) % 10;
            int n = i % 10;
            if(i == (int)Math.pow(z,3) + (int)Math.pow(y,3) + (int)Math.pow(n,3)){
                is_num = 1;
            }
            if(is_num == 1){
                System.out.println(i);
        }

        }
    }
}
